<#include "/common/layout.html">
<@body>
<div class="content">
	<form method="post" class="form-horizontal" action="${request.contextPath}/system/menu/doEdit" id="editForm">
	   	<input type="hidden" name="menuId" value="${(sysMenu.menuId)!}" />
		<div class="box-body">
			<div class="form-group">
				<label class="col-sm-2 control-label">编码</label>
				<div class="col-sm-10">
					<input type="text" name="code" class="form-control" placeholder="请输入编码,如05" value="${(sysMenu.code)!}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">目录名称</label>
				<div class="col-sm-10">
					<input type="text" name="menuName" class="form-control" value="${(sysMenu.menuName)!}" placeholder="请输入目录名称" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">排序</label>
				<div class="col-sm-10">
					<input type="text" name="sort" class="form-control" value="${(sysMenu.sort)!}"  placeholder="请输入排序"  required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">图标</label>
				<div class="col-sm-10">
					<span class="form-control">当前图标为：<i id="dirIcon" class="${(sysMenu.icon)!}"></i>  
						<a href="javascript:void(0);" onclick="selectIcon(1)" class="pull-right">
							 点击选取图标
						</a>
					</span>
					<input type="hidden" class="form-control"  name="icon"  id="folderIcon" value="${(sysMenu.icon)!}">
				</div>
			</div>
	  	</div>
	</form>
</div>
</@body>
<script type="text/javascript">
function submitHandler() {
	if ($("#editForm").validate().form()) {
			var formData = $("#editForm").serialize();
			var index = layer.load(3); // 换了种风格
			$.ajax({
				url : $("#editForm").attr('action'),
				type : 'POST',
				dataType : "json",
				data : formData,
				beforeSend : function() {
					$.modal.loading("正在处理中，请稍后...");
					$.modal.disable();
				},
				success : function(data) {
					layer.close(index);
					if (data.code == 200) {
						if (data.msg) {
							parent.layer.msg(data.msg, {
								icon : 1
							});
						} else {
							parent.layer.msg('提交成功', {
								icon : 1
							});
						}
						parent.layer.closeAll('iframe'); // 关闭当前frame
						window.parent.dataTable.draw(false);
					} else {
						layer.msg(data.msg, {
							icon : 2
						});
						$.modal.closeLoading();
						$.modal.enable();
					}
				}
			});
		}
	}
	function selectIcon(type) {
		var layerIndex = parent.layer.getFrameIndex(window.name);
		parent.layer.open({
			type : 2,
			title : '选取图标',
			closeBtn : 1,
			anim : -1,
			isOutAnim : false,
			shadeClose : false,
			shade : 0.3,
			area : [ '95%', '90%' ],
			content : '${request.contextPath}/toicon',
			btn : [ '确定', '取消' ],
			yes : function(index, layero) {
				var iframeWin = layero.find('iframe')[0];
				iframeWin.contentWindow.submitHandler(index,layero);
			},
			success : function(layero, index) {
				var body = parent.layer.getChildFrame('body', index);
				body.find("#sid").attr("iconType", type + "," + layerIndex);
			}
		});
	}
</script>
